home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Rund2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1998-12-29
|
2KB
|
75 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Rund2.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
class TKreis
{
public:
int x, y, Dicke;
void Erscheinen (void);
void Bewegen (void);
void Verschwinden (void);
TKreis (int xx, int yy, int dd);
};
TKreis *Kreis;
TForm1 *Form1;
//---------------------------------------------------------------------------
TKreis::TKreis(int xx, int yy, int dd)
{
x = xx; y = yy; Dicke = dd;
}
//---------------------------------------------------------------------------
void TKreis::Erscheinen (void)
{
Form1->Canvas->Ellipse (x, y, x+Dicke, y+Dicke);
}
//---------------------------------------------------------------------------
void TKreis::Bewegen (void)
{
TRect Quelle, Ziel;
for (int i=x-5; i<Form1->ClientWidth-Dicke-x-5; i++)
{
Quelle = Rect(i, y-5, i+Dicke+5, y+Dicke+5);
Ziel = Rect(i+1, y-5, i+Dicke+6, y+Dicke+5);
Form1->Canvas->CopyRect(Ziel, Form1->Canvas, Quelle);
// Bremse, abhΣngig vom Prozessortakt!
for (int j=0; j<1000000; j++) ;
}
}
//---------------------------------------------------------------------------
void TKreis::Verschwinden (void)
{
Form1->Refresh ();
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Kreis->Erscheinen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Kreis->Bewegen ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Kreis->Verschwinden ();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Kreis = new TKreis (30, 30, 150);
}
//---------------------------------------------------------------------------